﻿using System.Threading.Tasks;

namespace SwissTransTracker
{
    public static partial class Api
    {
        /// <summary>
        ///     Get's all the possible stops around a location
        /// </summary>
        /// <param name="startLocation">the location the go for</param>
        /// <returns>A list with possible locations</returns>
        public static async Task<LocationList> GetLocations(string startLocation)
        {
            return await Fetch<LocationList>("http://transport.opendata.ch/v1/locations?query=" + startLocation);
        }

        /// <summary>
        ///     Get's all the possible stops around a location
        /// </summary>
        /// <param name="startLocation">the location the go for</param>
        /// <param name="type">The type of location to go for</param>
        /// <returns>A list with possible locations</returns>
        public static async Task<LocationList> GetLocations(string startLocation, string type)
        {
            return
                await
                Fetch<LocationList>("http://transport.opendata.ch/v1/locations?query=" + startLocation + "&type=" +
                                    type.ToLowerInvariant());
        }

        /// <summary>
        ///     Get's all the possible stops around a location
        /// </summary>
        /// <param name="startLocation">the location the go for</param>
        /// <param name="x">the x coord to search around</param>
        /// <param name="y">the y coord to search around</param>
        /// <returns>A list with possible locations</returns>
        public static async Task<LocationList> GetLocations(string startLocation, double x, double y)
        {
            return
                await
                Fetch<LocationList>("http://transport.opendata.ch/v1/locations?query=" + startLocation + "&x=" + x +
                                    "&y=" + "&type=" + y);
        }

        /// <summary>
        ///     Get's all the possible stops around a location
        /// </summary>
        /// <param name="startLocation">the location the go for</param>
        /// <param name="x">the x coord to search around</param>
        /// <param name="y">the y coord to search around</param>
        /// <param name="type">The type of location to go for</param>
        /// <returns>A list with possible locations</returns>
        public static async Task<LocationList> GetLocations(string startLocation, double x, double y,
                                                            string type)
        {
            return
                await
                Fetch<LocationList>("http://transport.opendata.ch/v1/locations?query=" + startLocation + "&x=" + x +
                                    "&y=" + "&type=" + y + "&type=" + type.ToLowerInvariant());
        }
    }
}